﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DAL.EstRec;
using System.Data;


namespace BAL.EstRec
{
    public class Territorio
    {
        public string idGerencia { get; set; }
        public string gerencia { get; set; }
        public string idSupervision { get; set; }
        public string supervision { get; set; }
        public string idTerritorio { get; set; }
        public string territorio { get; set; }

        public Territorio(string id_territorio)
        {
            this.idTerritorio = id_territorio;
            GetDataTerritorio();
        }//constructor

        private void GetDataTerritorio()
        {
            if (String.IsNullOrEmpty(this.idTerritorio))
                return;

            DataTable dt = new DataTable();

            string query = "SP_ER_GET_TERRITORIO @IDTERRITORIO = @@idTerr";
            query = query.Replace("@@idTerr" , this.idTerritorio);

            try
            {
                    dt = SrvDB.ExecuteQuery(query);
                    if (dt.Rows.Count>0)
                    {
                        this.idGerencia  = dt.Rows[0]["ID_GERENCIA"].ToString();
                        this.gerencia = dt.Rows[0]["GERENCIA"].ToString();
                        this.idSupervision = dt.Rows[0]["ID_SUPERVISOR"].ToString();
                        this.supervision = dt.Rows[0]["SUPERVISOR"].ToString();
                        this.territorio = dt.Rows[0]["TERRITORIO"].ToString();
                    }
            }
            catch (Exception ex)
            {
                //throw ex;
                Console.WriteLine(ex.Message);
            }
        }//


    }//end class
}
